package sif.Activity;

import sif.Static.FacebookObjects;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;

public class MasterActivity extends TabActivity {

//	LinearLayout topFrame;
//	LinearLayout contentFrame;
//	LinearLayout botFrame;
//
//	LayoutInflater inflater;

	FacebookObjects fbObjects;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tabhost);

		TabHost tabHost = getTabHost(); // The activity TabHost
//		tabHost.setup();
        TabHost.TabSpec spec; // Resusable TabSpec for each tab
        Intent intent; // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, MyFriendActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost

        // My Friend tabs
        spec = tabHost.newTabSpec("myfriend").setIndicator("", getResources().getDrawable(R.drawable.friends))
                .setContent(intent);
        tabHost.addTab(spec);

        // New Feeds tabs
        intent = new Intent().setClass(this, NewFeedActivity.class);
        spec = tabHost.newTabSpec("newfeed").setIndicator("", getResources().getDrawable(R.drawable.new_feed1))
                .setContent(intent);
        tabHost.addTab(spec);

        // Home tabs
        intent = new Intent().setClass(this, HomeActivity.class);
        spec = tabHost.newTabSpec("myhome").setIndicator("", getResources().getDrawable(R.drawable.home))
                .setContent(intent);
        tabHost.addTab(spec);
        
        // Profile tabs
        intent = new Intent().setClass(this, ProfileActivity.class);
        spec = tabHost.newTabSpec("myprofile").setIndicator("", getResources().getDrawable(R.drawable.profile))
                .setContent(intent);
        tabHost.addTab(spec);
        
        // Album tabs
        intent = new Intent().setClass(this, AlbumActivity.class);
        spec = tabHost.newTabSpec("myalbum").setIndicator("", getResources().getDrawable(R.drawable.album))
                .setContent(intent);
        tabHost.addTab(spec);
        
        tabHost.setCurrentTab(0);
        
        tabHost.setOnTabChangedListener(new OnTabChangeListener() {
			
			@Override
			public void onTabChanged(String tabId) {
				// TODO Auto-generated method stub
				Log.i("thaile", "tabID : " + tabId);
			}
		});
        
//        // History tabs
//        intent = new Intent().setClass(this, HistoryActivity.class);
//        spec = tabHost.newTabSpec("history").setIndicator("History", null)
//                .setConten	t(intent);
//        tabHost.addTab(spec);
//
//        // Setting tabs
//        intent = new Intent().setClass(this, SettingActivity.class);
//        spec = tabHost.newTabSpec("setting").setIndicator("Setting", null)
//                .setContent(intent);
//        tabHost.addTab(spec);
		
//		topFrame = (LinearLayout) findViewById(R.id.layoutTopMenu);
//		contentFrame = (LinearLayout) findViewById(R.id.layoutContent);
//		botFrame = (LinearLayout) findViewById(R.id.layoutBottomMenu);
//
//		inflater = getLayoutInflater();
//		View topMenu = inflater.inflate(R.layout.top_menu, null);
//		View botMenu = inflater.inflate(R.layout.bot_menu, null);
//
//		topFrame.addView(topMenu);
//		botFrame.addView(botMenu);
//
//		Display display = getWindowManager().getDefaultDisplay();
//		int screenWidth = display.getWidth();
//		int screenHeight = display.getHeight();
//
//		// 40*2 top + menu height and 50 is app title height
//		int contentHeight = screenHeight - (100 + 100 + 100);
//
//		Log.i("width", "" + screenWidth);
//		Log.i("height", "" + screenHeight);
//		Log.i("contentHeight", "" + contentHeight);
//
//		topFrame.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, 100));
//		contentFrame.setLayoutParams(new LinearLayout.LayoutParams(screenWidth,
//				contentHeight));
//		botFrame.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, 150));
//
//		Log.i("Theight", "" + topFrame.getHeight());
//		Log.i("Cheight", "" + contentFrame.getHeight());
//		Log.i("Bheight", "" + botFrame.getHeight());
//		
//		((Button) findViewById(R.id.btHome)).setOnClickListener(this);
//		((Button) findViewById(R.id.btFriends)).setOnClickListener(this);
//		((Button) findViewById(R.id.btProfile)).setOnClickListener(this);
//		((Button) findViewById(R.id.btNewFeeds)).setOnClickListener(this);
//		((Button) findViewById(R.id.btAlbum)).setOnClickListener(this);
		
		//init components
		initComponents();
		
	}
	
	public void initComponents(){
		fbObjects = FacebookObjects.getFacebookObjects();
	}
	
//
//	@Override
//	public void onClick(View v) {
//		// TODO Auto-generated method stub
////		switch (v.getId()) {
////		case R.id.btFriends:
////			Intent myFiendActivity = new Intent(MasterActivity.this, MyFriendActivity.class);
////			startActivity(myFiendActivity);
////			break;
////		case R.id.btHome:
////			Intent newFeedActivity = new Intent(MasterActivity.this, NewFeed.class);
////			startActivity(newFeedActivity);
////			break;
////		default:
////			break;
////		}
//	}

	

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		fbObjects.getFacebook().authorizeCallback(requestCode, resultCode, data);
	}

}
